<div class="row">
    <div class="colxl-12 col-lg-12 col-md-12 col-sm-12 col-12">
        <div class="page-title-wrapper">
            <div class="page-title-box">
                <h4 class="page-title bold">个人资料</h4>
            </div>
            <div class="breadcrumb-list">
                <ul>
                    <li class="breadcrumb-link"><a th:href="@{admin}"><i class="fas fa-home mr-2"></i>首页</a></li>
                    <li class="breadcrumb-link active">用户</li>
                    <li class="breadcrumb-link active">个人资料</li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!-- Main content -->
<!-- Main content -->
<section class="content">
<div class="card table-info card-body">
    <form id="userForm">
        <input type="hidden" name="id" th:value="${user?.id}">
        <div th:if="${user?.username != null}" class="form-group row">
            <label for="username" class="col-sm-3 col-form-label">用户名:</label>
            <div class="col-sm-9">
                <input type="text" th:value="${user?.username}" readonly="readonly"
                       name="username" class="form-control" id="username"
                       placeholder="填写用户名" required>
                <div class="invalid-feedback">请填写用户名</div>
            </div>
        </div>
        <div th:if="${user?.username == null}" class="form-group row">
            <label for="username" class="col-sm-3 col-form-label">用户名:</label>
            <div class="col-sm-9">
                <input type="text" th:value="${user?.username}"
                       name="username" class="form-control" id="username"
                       placeholder="填写用户名" required>
                <div class="invalid-feedback">请填写用户名</div>
            </div>
        </div>
        <div th:if="${user?.username == null}" class="form-group row">
            <label for="password" class="col-sm-3 col-form-label">密码:</label>
            <div class="col-sm-9">
                <input type="password" name="password" class="form-control" id="password"
                       placeholder="请填写密码" required>
                <div class="invalid-feedback">请填写密码:</div>
            </div>
        </div>
        <div th:if="${user?.username == null}" class="form-group row">
            <label for="confirmPassword" class="col-sm-3 col-form-label">确认密码:</label>
            <div class="col-sm-9">
                <input type="password" name="confirmPassword" class="form-control" id="confirmPassword"
                       placeholder="请填写密码" required>
                <div class="invalid-feedback">请填写确认密码</div>
            </div>
        </div>
        <div class="form-group row">
            <label for="nickname" class="col-sm-3 col-form-label">昵称:</label>
            <div class="col-sm-9">
                <input type="text" th:value="${user?.nickname}" name="nickname" class="form-control"
                       id="nickname"
                       placeholder="请填写昵称" required>
                <div class="invalid-feedback">请填写昵称</div>
            </div>
        </div>
        <div class="form-group row">
            <label for="email" class="col-sm-3 col-form-label">邮箱:</label>
            <div class="col-sm-9">
                <input type="text" th:value="${user?.email}" name="email" class="form-control"
                       id="email"
                       placeholder="请填写邮箱" required>
                <div class="invalid-feedback">请填写邮箱</div>
            </div>
        </div>
        <div class="form-group row">
            <label for="phone" class="col-sm-3 col-form-label">电话:</label>
            <div class="col-sm-9">
                <input type="text" th:value="${user?.phone}" name="phone" class="form-control"
                       id="phone"
                       placeholder="请填写电话" required>
                <div class="invalid-feedback">请填写电话</div>
            </div>
        </div>
        <div class="form-group row">
            <label for="sex" class="col-sm-3 col-form-label">性别:</label>
            <div class="col-sm-9">
                <select id="sex" name="sex" class="form-control" required>
                    <option th:selected="${user?.sex==1}" value="1">男</option>
                    <option th:selected="${user?.sex==2}" value="2">女</option>
                </select>
                <div class="invalid-feedback">请选择性别</div>
            </div>
        </div>
        <div class="form-group row">
            <label for="age" class="col-sm-3 col-form-label">年龄:</label>
            <div class="col-sm-9">
                <input type="number" th:value="${user?.age}" name="age" class="form-control"
                       id="age"
                       placeholder="请填写年龄" required>
                <div class="invalid-feedback">请填写年龄</div>
            </div>
        </div>
    </form>
</div>
</section>

<script type="text/javascript">
    $(function () {
        $("#saveInfo").on('click', function () {
            Core.mask("#saveInfo");
            Core.postAjax("/user/edit",$("#userInfoForm").serialize(),function (data) {
                Core.unmask("#saveInfo");
                layer.msg(data.msg);
            })

        })
    });
</script>


